package com.example.android.thread.base;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.example.androidthread.R;

public  abstract  class BaseActivity extends AppCompatActivity {
    private TextView titleTV;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(gerLayoutID());
        initView();
        initData();
    }

    protected void initView(){
        titleTV = findViewById(R.id.titleTV);
        Button backBtn =  findViewById(R.id.backBTN);

        if (backBtn != null){
            backBtn.setOnClickListener(v -> finish());
        }
    }

    protected abstract  int gerLayoutID();

    protected   void  setTitleTV(String titleStr){
        if (titleTV != null){
            titleTV.setText(titleStr);
        }
    }

    public void initData(){}

}
